import { gsap } from "gsap"

const ANIMATIONS = {
    transitGraph(app, loadGraphData) {
        const transitGraphTimeline = gsap.timeline({
            defaults: {
                duration: 0.5
            }
        });
        
        transitGraphTimeline
            //.addLabel("start")
            .to(".div-graph-container", {
                duration: 0.3,
                opacity: 0,
                onComplete: () => {
                    loadGraphData();
                }
            })
            .to(".div-graph-container", {
                opacity: 1,
                onComplete: () => {
                    app.isLoading = false;
                    // the progress reset should not be implemented with fromTo because
                    // value changes of progress bar are smoothly animated.
                    app.graphTransitionProgress = 0;
                }
            },"+=5");
    },

    startProgress(app) {
        gsap.to(app, {
            graphTransitionProgress: 100,
            duration: 5
        });
    },

    showEntityDetail(app) {
        app.isDialogShow = true;

        gsap.to(app, {
            dialogOpacity: 1,
            duration: 0.3
        });
    },

    hideEntityDetail(app) {
        gsap.to(app, {
            dialogOpacity: 0,
            duration: 0.3,
            onComplete: () => {
                app.isDialogShow = false;
            }
        });
    }
};

export default ANIMATIONS;